package action;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import util.AnotationParser;

public class ActionListener implements ServletContextListener{

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		
	}

	@Override
	public void contextInitialized(ServletContextEvent servletContextEvent) {
		ServletContext context = servletContextEvent.getServletContext();
		String packagePath = context.getInitParameter("PackagePath");
		String tomcatpath =context.getRealPath("\\");
		System.out.println("tomcatpath="+tomcatpath);
		System.out.println("packagePath="+packagePath);		
		
		try {
			context.setAttribute("anotation", AnotationParser.anotationParse(tomcatpath, packagePath));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
